CLB 2nd PR: Add DiffTracker core types, state management, and sync operations#10068
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Hi @georgeedward2000. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
e829a97 to
21eafd4
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: georgeedward2000 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| ResourceTypeEgress = "Egress" | ||
| ) | ||
|
|
||
| func updateK8Resource(input UpdateK8sResource, set *utilsets.IgnoreCaseSet, resourceType string) error { |
There was a problem hiding this comment.
can we make it updateK8sResources, or updateKubernetesResources, or enqueueOperation?
Introduces the difftracker package with core K8s/NRP state tracking, diff computation, and state mutation logic. Includes comprehensive test coverage (25+ test functions).
9782742 to
0760d17
Compare
| // enqueueK8sResourceOperation applies the requested operation (ADD/REMOVE) to the | ||
| // in-memory K8s resource set. It does not perform any Azure update calls; it only | ||
| // mutates the local desired-state model that will later be reconciled with NRP. | ||
| func enqueueK8sResourceOperation(input UpdateK8sResource, set *utilsets.IgnoreCaseSet, resourceType string) error { |
There was a problem hiding this comment.
Any reason why this is not a private method of diffTracker? All other funcs here are under diffTracker.
| // DiffTracker keeps track of the state of the K8s cluster and NRP | ||
| // -------------------------------------------------------------------------------- | ||
| type NRPAddress struct { | ||
| Services *utilsets.IgnoreCaseSet // all inbound and outbound identities |
There was a problem hiding this comment.
Does it store kubernetes service names?
| } | ||
|
|
||
| type NRPLocation struct { | ||
| Addresses map[string]NRPAddress |
There was a problem hiding this comment.
Could you please elaborate what address mean in the context of containerLB?
| type NRPState struct { | ||
| LoadBalancers *utilsets.IgnoreCaseSet | ||
| NATGateways *utilsets.IgnoreCaseSet | ||
| Locations map[string]NRPLocation |
There was a problem hiding this comment.
Is Location geological region, like eastus2?
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR introduces the DiffTracker core package — the foundational types, state management, and diff computation logic for the Container Load Balancer (CLB) feature.
The DiffTracker maintains two parallel state representations:
It provides operations to mutate both states and compute the diff between them, determining what needs to be synced to Azure.
Package contents (
pkg/provider/difftracker/):types.goOperation,UpdateAction,SyncStatus), K8s/NRP state model types,DiffTrackerstruct, input types, sync result typesconfig.goConfigstruct with Azure subscription, resource group, location, and ServiceGateway fieldsdifftracker.goInitializeDiffTracker()constructor with validationk8s_state_updates.gonrp_state_updates.gosync_operations.goGetSyncOperations,GetSyncLoadBalancerServices,GetSyncNRPNATGateways,GetSyncLocationsAddresses)util.goDeepEqual,Equalscomparison methodsDependency changes (
pkg/util/sets/string.go):Equals()method toIgnoreCaseSetfor set comparisonMarshalJSON()method toIgnoreCaseSetfor JSON serializationTest coverage:
difftracker_test.go— 14 test functions covering initialization, state updates, sync operations, and end-to-end scenariosutil_test.go— 11 test functions covering enum serialization, JSON round-trips,HasPods/HasIdentitieshelpers,DeepEqual,Equals, andConfig.Validate()string_test.go— AddedTestEquals(8 sub-tests) for the newIgnoreCaseSet.Equals()methodThis is PR 2 in the CLB series, building on the configuration and constants from PR 1 (#9775). Engine-layer code (async processing, updaters, finalizers, metrics, Azure operations) and ServiceGateway API DTOs/mappers are intentionally excluded and will follow in subsequent PRs.
Which issue(s) this PR fixes:
Part of CLB (Container Load Balancer) feature implementation.
Special notes for your reviewer:
isServiceReady()function currently checks NRP state only. In the engine PR (PR 3), it will be extended to also checkpendingServiceOpsforStateCreatedstatus.DEFERRED_CODE_TRACKER.mdis maintained in the source repo tracking what was excluded and which future PR will add it back.Does this PR introduce a user-facing change?